﻿$(function(){
	//当前页选中
	var _html = window.location.href;
	var url = _html.split("/");
	var nnn = url[url.length-1];
	_html = nnn.substr(0,(nnn.length-5));
	$("#menu1 a").each(function(){
		if($(this).attr("href") == _html){
			$(this).addClass("hover");
		};
	})

	$("#menu1 li>a").on("click",function(){
		$(this).addClass("hover").parents("li").siblings().find("a").removeClass("hover");
		if($(this).next("ul").length > 0){
			$(this).next("ul").slideDown();
		}
	})
	//套餐流量鼠标上移显示详细内容
	if($(".otherCombo li").length > 0){
		$(".otherCombo li").hover(function(){
			$(this).find(".blackbg").css({"height":"100%"});
			$(this).find(".cont").css({"top":"0"});
		},function(){
			$(this).find(".blackbg").css({"height":"35px"});
			$(this).find(".cont").css({"top":"98px"});
		})
	}
	//登录注册页内容居中
	function setauto(){
		var _height = $(window).height();
		$(".login").css({"height":_height});
		$(".loginTitle").css({"top":((_height - 330)/2 - 100)})
		$(".mainLogin").css({
			"top":(_height - 420)/2,
			"left":($(window).width() - 420)/2
		});
	}
	if($(".login").length > 0){
		$(window).resize(function() {
			setauto();
		});
		setauto();
	}
	
	//发送设置页样式
	if($(".js-switch").length > 0){
		var elem = document.querySelector('.js-switch');
		var switchery = new Switchery(elem, {
			color: '#00a0e9'
		});
	}
	if($("#ionrange_1").length > 0){
		$("#ionrange_1").ionRangeSlider({
		min: 0,
		max: 24,
		type: 'double',
		postfix: ":00",
		prettify: false,
		hasGrid: true
		});
	}
})
//发送验证码倒计时
/*
*@description 发送验证码
*@param <Object> o 按钮本身
*@param <String> faction 请求后台的路径
*/
var wait = 60;
function time(o) {
	if (wait == 0) {
		o.removeAttribute("disabled");
		o.value = "点击发送";
		wait = 60;
		clearTimeout();
	} else {
		o.setAttribute("disabled", true);
		o.value = "重新发送(" + wait + ")";
		wait--;
		setTimeout(function () {
			time(o);
		}, 1000);
	}
}

//收藏页全选按钮事件
function checkAll(self) {
	var CheckBox = document.getElementsByTagName('input');
	var ischeckall = $(self).find("input").is(":checked");
	if (ischeckall) {
		for (i = 0; i < CheckBox.length; i++) {
			CheckBox[i].checked = true;
		};
	} else {
		for (i = 0; i < CheckBox.length; i++) { CheckBox[i].checked = false; };
	}
}